﻿using Core.DataAccess.Model.Project.Order;
using Core.Framework.Model.Common;
using Core.IBusiness.IOrderModule.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Core.IBusiness.IOrderModule
{
    /// <summary>
    /// 订单相关操作
    /// </summary>
    public interface IOrder
    {
        /// <summary>
        /// 下订单
        /// </summary>
        /// <param name="orderBasis">基础模型</param>
        /// <param name="products">订单产品</param>
        /// <param name="address">配送地址</param>
        /// <returns>订单关键字</returns>
        MethodResult<int> PlaceTheOrder(OrderBasis orderBasis, List<OrderProduct> products, OrderAddress address);

        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="project_token">项目Token</param>
        /// <returns></returns>
        MethodResult<int> DeleteOrder(int order_key, string project_token);

        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="project_token">项目Token</param>
        /// <returns></returns>
        MethodResult<int> CancelOrder(int order_key, string project_token);

        /// <summary>
        /// 修改订单付款金额
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="price">修改金额</param>
        /// <param name="project_token">项目Token</param>
        /// <returns></returns>
        MethodResult<int> OrderPaymentUpdate(int order_key, decimal price, string project_token);

        /// <summary>
        /// 订单付款
        /// </summary>
        /// <param name="payment_ordel">付款数据模型</param>
        /// <returns></returns>
        MethodResult<int> OrderPayment(OrderPay payment_ordel);

        /// <summary>
        /// 订单产品发货
        /// </summary>
        /// <param name="shipmentses">发货模型</param>
        /// <returns></returns>
        MethodResult<int> OrderShipments(List<OrderShipments> shipmentses);

        /// <summary>
        /// 订单评论
        /// </summary>
        /// <param name="orderProductKey">订单商品关键字[非产品ID]</param>
        /// <returns></returns>
        MethodResult<int> OrderComment(int orderProductKey);

        /// <summary>
        /// 订单产品发货确认
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="user_key">确认人</param>
        /// <param name="complete_time">确认时间</param>
        /// <returns></returns>
        MethodResult<int> OrderShipmentsConfirm(int order_key, int user_key, DateTime complete_time);

        /// <summary>
        /// 订单退货申请
        /// </summary>
        /// <param name="returnses">退货申请模型集合</param>
        /// <returns></returns>
        MethodResult<int> OrderReturnsApply(List<OrderReturns> returnses);

        /// <summary>
        /// 订单产品退货
        /// </summary>
        /// <param name="shipmentses">产品退货模型集合</param>
        /// <returns></returns>
        MethodResult<int> OrderReturns(List<OrderShipments> shipmentses);

        /// <summary>
        /// 订单退款申请
        /// </summary>
        /// <param name="refund">退货申请模型</param>
        /// <returns></returns>
        MethodResult<int> OrderRefundApply(OrderRefund refund);

        /// <summary>
        /// 退款申请状态处理
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="status">处理状态</param>
        /// <param name="update_last_time">操作时间</param>
        /// <returns></returns>
        MethodResult<int> OrderRefundStuas(int order_key, OrderBitStatu status, DateTime update_last_time);

        /// <summary>
        /// 退款订单修改订单金额
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="order_refund_key">退款关键字</param>
        /// <param name="price">修改金额</param>
        /// <returns></returns>
        MethodResult<int> OrderRefundUpdate(int order_key, int order_refund_key, decimal price);

        /// <summary>
        /// 退款订单支付完成
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="payment"></param>
        /// <param name="complete">操作时间</param>
        /// <returns></returns>
        MethodResult<int> OrderRefundPay(int order_key, decimal payment, DateTime complete);

        /// <summary>
        /// 修改地址
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="content">地址信息</param>
        /// <returns></returns>
        MethodResult<int> OrderAddressUpdate(int order_key, string content);

        /// <summary>
        /// 修改指定产品收货地址
        /// </summary>
        /// <param name="order_key">订单号</param>
        /// <param name="content">地址信息</param>
        /// <param name="product_key">产品关键字</param>
        /// <returns></returns>
        MethodResult<int> OrderAddressUpdate(int order_key, string content, int product_key);

        /// <summary>
        /// 订单申请售后
        /// </summary>
        /// <param name="model">订单申请服务模型</param>
        /// <returns></returns>
        MethodResult<int> OrderServeApply(OrderServe model);

        /// <summary>
        /// 修改售后相关信息
        /// </summary>
        /// <param name="OrderServe">订单申请服务关键字</param>
        /// <param name="content">内容信息</param>
        /// <returns></returns>
        MethodResult<int> OrderServeUpdate(int OrderServe, string content);

        /// <summary>
        /// 订单额外事件
        /// </summary>
        /// <param name="model">额外事件模型</param>
        /// <returns></returns>
        MethodResult<int> OrderAccident(OrderAccident model);

        /// <summary>
        /// 订单日志
        /// </summary>
        /// <param name="model">订单日志模型</param>
        /// <param name="type">日志类型</param>
        /// <returns></returns>
        MethodResult<int> OrderLog(OrderLog model, OrderLogType type);

        /// <summary>
        /// 加入用户购物车
        /// </summary>
        /// <param name="model">用户购物车模型</param>
        /// <returns></returns>
        MethodResult<int> AddUserCart(OrderUserCart model);

        /// <summary>
        /// 删除用户购物车
        /// </summary>
        /// <param name="cart_key">购物车关键字</param>
        /// <param name="project_token">项目Token</param>
        /// <returns></returns>
        MethodResult<int> DeleteUserCart(int cart_key, string project_token);

        /// <summary>
        /// 修改购物车数量信息
        /// </summary>
        /// <param name="model">购物车模型</param>
        /// <returns></returns>
        MethodResult<int> UpdateUserCartItem(OrderUserCart model);

        /// <summary>
        /// 根据购物车下单
        /// </summary>
        /// <param name="userCarts">购物车模型集合</param>
        /// <param name="orderBasis">基础模型</param>
        /// <param name="address">配送地址</param>
        /// <returns></returns>
        MethodResult<int> UserCartOrder(OrderBasis orderBasis, OrderAddress address, List<OrderUserCart> userCarts);

        /// <summary>
        /// 获取用户购物车
        /// </summary>
        /// <param name="user_key">用户关键字</param>
        /// <param name="project_token">项目Token</param>
        /// <param name="pagination">分页信息</param>
        /// <returns></returns>
        MethodResult<List<OrderUserCart>> GetUserCart(int user_key, string project_token, Pagination pagination);

        /// <summary>
        /// 查询用户订单
        /// </summary>
        /// <param name="project_token"></param>
        /// <param name="order_statu">订单状态</param>
        /// <param name="order_type">订单类型</param>
        /// <param name="pagination">分页信息</param>
        /// <returns></returns>
        MethodResult<List<OrderBasis>> GetOrder(string project_token, OrderStatus order_statu, OrderType order_type, Pagination pagination);

        /// <summary>
        /// 查询指定用户订单
        /// </summary>
        /// <param name="user_key">用户关键字</param>
        /// <param name="project_token">项目Token</param>
        /// <param name="order_statu">订单状态</param>
        /// <param name="order_type">订单类型</param>
        /// <param name="pagination">分页信息</param>
        /// <returns></returns>
        MethodResult<List<OrderBasis>> GetOrderUser(int user_key, string project_token, OrderStatus order_statu, OrderType order_type, Pagination pagination);

        /// <summary>
        /// 查询用户单笔订单详情
        /// </summary>
        /// <param name="order_key">订单关键字</param>
        /// <param name="project_token">项目Token</param>
        /// <returns></returns>
        MethodResult<OrderBasis> GetOrderItem(int order_key, string project_token);

        /// <summary>
        /// 查询用户单笔订单详情
        /// </summary>
        /// <param name="order_key">订单关键字</param>
        /// <param name="project_token">项目Token</param>
        /// <param name="isTrackNodeService">查询物流</param>
        MethodResult<object> GetOrderItem(int order_key, string project_token, bool isTrackNodeService);

        /// <summary>
        /// 订单统计
        /// </summary>
        /// <param name="user_key">用户关键字</param>
        /// <param name="project_token">项目Token</param>
        /// <returns></returns>
        MethodResult<Dictionary<string, int>> GetOrderCount(int user_key, string project_token);


        /// <summary>
        /// 用户地址信息操作
        /// </summary>
        /// <param name="model">用户地址信息</param>
        /// <param name="sqlExecType">操作类型</param>
        /// <returns></returns>
        MethodResult<int> UserAddressExec(OrderUserAddress model, SqlExecType sqlExecType);

        /// <summary>
        /// 获取指定用户配置地址信息
        /// </summary>
        /// <param name="model">查询模型</param>
        /// <returns></returns>
        MethodResult<List<OrderUserAddress>> GetUserAddress(OrderUserAddress model);
    }
}
